package com.cn.file;

import org.apache.commons.lang3.StringUtils;

import java.io.File;

public class MessageStoreConfig {

    //根目录
    private String storePathRootDir = System.getProperty("user.home") + File.separator + "rocketmq";

    //commitlog文件路径
    private String storePath = System.getProperty("user.home") + File.separator + "rocketmq" + File.separator + "data" + File.separator + "commitlog" + File.separator;

    //consumequeue文件路径
    private String storeConsumePath = storePath + File.separator + "consumequeue";

    private String indexPath = storePath + File.separator + "index";

    //消息存储文件大小
    private int mappedFileSize = 1024 * 1024 * 100;//100M

    //刷盘间隔 0.5s
    private int flushIntervalCommitLog = 500;

    private int flushLeastPages = 4;

    //彻底刷盘间隔时间（默认10s）
    private int flushCommitLogThoroughInterval = 10000;

    //0.5s
    private int lockInerval = 500;

    //consumequeue文件大小(存放的每条消息固定大小20字节，所以文件大小必须是20的倍数)
    private int consumeFileSize = 1024 * 1024 * 100;

    private String FlushDiskType;

    //4m
    private int maxMessageSize = 1024 * 1024 * 4;

    public MessageStoreConfig(String storePath, Long mappedFileSize) {
        if (StringUtils.isNotEmpty(storePath)) {
            this.storePath = storePath;
        }
        this.storeConsumePath = this.storePath + File.separator + "consumequeue";
        this.mappedFileSize = mappedFileSize.intValue();
    }

    public MessageStoreConfig(String storePathRootDir, String storePath, Long mappedFileSize) {
        this.mappedFileSize = mappedFileSize.intValue();
        if (StringUtils.isNotEmpty(storePath)) {
            this.storePath = storePath;
        }
        this.storePathRootDir = storePathRootDir;
        this.storeConsumePath = storePathRootDir + File.separator + "consumequeue";
        this.indexPath = storePathRootDir + File.separator + "index";
    }

    public String getStorePath() {
        return storePath;
    }

    public void setStorePath(String storePath) {
        this.storePath = storePath;
    }

    public int getMappedFileSize() {
        return mappedFileSize;
    }

    public void setMappedFileSize(int mappedFileSize) {
        this.mappedFileSize = mappedFileSize;
    }

    public int getFlushIntervalCommitLog() {
        return flushIntervalCommitLog;
    }

    public int getFlushLeastPages() {
        return flushLeastPages;
    }

    public void setFlushLeastPages(int flushLeastPages) {
        this.flushLeastPages = flushLeastPages;
    }

    public int getFlushCommitLogThoroughInterval() {
        return flushCommitLogThoroughInterval;
    }

    public String getStorePathRootDir() {
        return storePathRootDir;
    }

    public int getLockInerval() {
        return lockInerval;
    }

    public String getFlushDiskType() {
        return FlushDiskType;
    }

    public void setFlushDiskType(String flushDiskType) {
        FlushDiskType = flushDiskType;
    }

    public int getConsumeFileSize() {
        return consumeFileSize;
    }

    public void setConsumeFileSize(int consumeFileSize) {
        this.consumeFileSize = consumeFileSize;
    }

    public int getMaxMessageSize() {
        return maxMessageSize;
    }

    public String getStoreConsumePath() {
        return storeConsumePath;
    }

    public String getIndexPath() {
        return indexPath;
    }


    public static void main(String[] args) {
        System.out.println(System.getProperty("user.home") + "" + File.separator);
    }

}
